package com.sikaryofficial.information.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sikaryofficial.common.security.utils.SecurityUtils;
import com.sikaryofficial.information.domain.entity.Article;
import com.sikaryofficial.information.mapper.ArticleMapper;
import com.sikaryofficial.information.service.IArticleService;
import com.sikaryofficial.system.api.model.infomation.ArticleDTO;
import com.sikaryofficial.system.api.model.infomation.ArticleListReq;
import com.sikaryofficial.system.api.model.infomation.KolListReq;
import com.sikaryofficial.system.api.model.infomation.StatuteListReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 文章Service业务层处理
 *
 * @author qinjinyuan
 * @date 2024-03-13
 */
@Service
public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> implements IArticleService {
    @Autowired
    private ArticleMapper articleMapper;

    /**
     * 文章分页列表数据
     *
     * @param customerPage
     * @param req
     * @return
     */
    @Override
    public IPage<ArticleDTO> articleList(Page<ArticleDTO> customerPage, ArticleListReq req) {
        return articleMapper.articleList(customerPage, req, SecurityUtils.getUserId());
    }

    /**
     * 法规分页列表数据
     *
     * @param customerPage
     * @param req
     * @return
     */
    @Override
    public IPage<ArticleDTO> statuteListPage(Page<ArticleDTO> customerPage, StatuteListReq req) {
        return articleMapper.statuteListPage(customerPage, req, SecurityUtils.getUserId());
    }

    /**
     * kol分页列表数据
     *
     * @param customerPage
     * @param req
     * @return
     */
    @Override
    public IPage<ArticleDTO> kolListPage(Page<ArticleDTO> customerPage, KolListReq req) {
        return articleMapper.kolListPage(customerPage, req, SecurityUtils.getUserId());
    }

    /**
     * 查询最新用户发布文章
     *
     * @param userId
     * @return
     */
    @Override
    public List<ArticleDTO> ownerLatest(Long userId, Integer tenantId) {
        return articleMapper.ownerLatest(userId, tenantId);
    }
}
